const http = require('http')
const url = require('url')
const qs = require('querystring');
const server = http.createServer((req, res) => {
  // if (req.url === '/home') {
  //   res.end('欢迎你的回来')
  // } else if (req.url === '/user') {
  //   res.end('用户列表')
  // } else {
  //   res.end('页面不存在')
  // }
  console.log(req.url)
  const { pathname, query} = url.parse(req.url)
  if (pathname === '/home') { 
    console.log('query=', query)
    const { username, password } = qs.parse(query)
    console.log(username, password)
    res.end('请求结果成功')
  }
})
server.listen(8001, () => {
  console.log('server开始监听')
})